Return oriented programming attack protection

ABSTRACT

A computer implemented method for preventing return-oriented programming (ROP) attacks includes registering one or more critical regions, wherein a critical region corresponds to an address that has been selected to be monitored for potential ROP attacks, identifying one or more critical functions, wherein a critical function corresponds to a function that has been selected to be analyzed as a potential ROP threat, instrumenting the one or more critical regions with ROP protection mechanisms, detecting a critical function execution attempt on one or more of the identified critical regions, determining whether values associated with the critical function match corresponding expected values, and, responsive to determining that values associated with the critical function do not match expected values, activating a return-oriented programming protection mechanism.

BACKGROUND OF THE INVENTION

The present invention relates generally to the field of computersecurity, and more specifically to preventing return-orientedprogramming attacks.

Return-oriented programming (ROP) is a technique for exploiting computersecurity wherein an attacker is able to execute code even in thepresence of security defenses, such as code signing and non-executablememory. In such an attack, the attacker manipulates a call stack tocontrol a program's control flow, and then executes specific machineinstruction sequences that already exist in the machine's memory, calledgadgets. Typically, a gadget located in a subroutine within either theexisting program or within a shared library code. Gadgets also typicallyend in a return instruction.

SUMMARY

As disclosed herein, a computer implemented method for preventingreturn-oriented programming (ROP) attacks includes registering one ormore critical regions, wherein a critical region corresponds to anaddress that has been selected to be monitored for potential ROPattacks, identifying one or more critical functions, wherein a criticalfunction corresponds to a function that has been selected to be analyzedas a potential ROP threat, instrumenting the one or more criticalregions with ROP protection mechanisms, detecting a critical functionexecution attempt on one or more of the identified critical regions,determining whether values associated with the critical function matchcorresponding expected values, and, responsive to determining thatvalues associated with the critical function do not match expectedvalues, activating a return-oriented programming protection mechanism. Acomputer program product and computer system corresponding to the methodare also disclosed.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a functional block diagram depicting a ROP detection system inaccordance with one embodiment of the present invention;

FIG. 2 is a flowchart depicting a ROP protection method in accordancewith one embodiment of the present invention;

FIG. 3 is a diagram depicting a sample address space in accordance withone embodiment of the present invention; and

FIG. 4 depicts a block diagram of components of a computer, inaccordance with some embodiments of the present invention.

DETAILED DESCRIPTION

Return Oriented Programming (ROP) is gaining attention in the securityindustry due to the lack of a reliable way to handle ROP attacks. Someimplementations provide hardware support to detect potential ROP attacksby building heuristics into hardware that can identify ROP attackpatterns and either report them or block them. These solutions, however,often lead to significant overhead required to process events associatedwith potential ROP attacks. The present invention as disclosed minimizesthe amount of hardware required to detect potential ROP attacks.

The present invention will now be described in detail with reference tothe Figures. Implementation of embodiments of the invention may take avariety of forms, and exemplary implementation details are discussedsubsequently with reference to the Figures.

FIG. 1 is a functional block diagram depicting a ROP detection system100 in accordance with one embodiment of the present invention. Thedepicted embodiment of ROP detection system 100 corresponds to acomputing system 110, but it should be noted that in additionalembodiments, an ROP detection system may include multiple computingsystems and one or more networks across which said multiple computingsystems may communicate.

Computing system 110 can be a desktop computer, laptop computer,specialized computer server, or any other computer system known in theart. In some embodiments, computing system 110 represents a computersystem utilizing clustered computers and components to act as a singlepool of seamless resources. In general, computing system 110 isrepresentative of any electronic device, or combinations of electronicdevices, capable of executing machine-readable program instructions, asdescribed in greater detail with regard to FIG. 4.

Hypervisor (or virtual machine monitor) 112 may be software, firmware,or hardware configured to create and run virtual machines. Hypervisor112 may be configured to provide guest operating systems with a virtualoperating platform and manage the execution of said guest operatingsystems. In the depicted embodiment, hypervisor 112 is configured tomanage the execution and operation of address 114 and critical addresses116. Additionally, hypervisor 112 may be configured to communicate withsecurity mechanisms 118, either to receive security information or toprovide security instructions to the security mechanisms 118.

Address 114 and critical addresses 116 may correspond to separatevirtual machine instances created or managed by hypervisor 112. Thedepicted embodiment includes two critical addresses 116 and a singleadditional address 114, but it should be appreciated that in otherembodiments of the present invention, any number of addresses andcritical addresses may be present within an ROP detection system.Address 114 may also be referred to as a non-critical address, as it issimply an address that has not been identified as a critical region withrespect to potential ROP attacks. In one embodiment, critical addresses116 are regions that are registered by the hypervisor 112 as “special”or critical. The critical regions correspond to address which a branch,jump, or return to may indicate a potential ROP attack.

Security mechanisms 118 may correspond to any known ROP protectionmechanism in the art. In one embodiment, security mechanisms 118correspond to shadow stack mechanisms. A shadow stack maintainscontrol-flow integrity by mitigating return address overwrites such asthose seen during exploitation of a stack buffer overflow. Shadow stacksfirst keep a record of legitimate return addresses for one or morefunction calls, and then check that a return address associated with acall is still correct before return. In other embodiments, securitymechanisms 118 correspond to one or more nested protection mechanismsacting together or separately to detect or prevent ROP attacks.

FIG. 2 is a flowchart depicting a ROP protection method 200 inaccordance with one embodiment of the present invention. As depicted,ROP attack detection method 200 includes registering (210) one or morecritical regions, identifying (220) one or more critical functions,instrumenting (230) the one or more critical regions with ROP protectionmechanisms, detecting (240) a critical function execution attempt on oneor more of the identified critical regions, determining (250) whethervalues associated with the critical function match expected values, andactivating (260) a return-oriented programming protection mechanism. ROPprotection method 200 provides protection from ROP attacks with minimalhardware requirements.

Registering (210) one or more critical regions may include a hypervisoror OS identifying one or more addresses (or special addresses). In atleast one embodiment, registering (210) one or more critical regionsincludes a security domain expert identifying one or more gadgets thatare commonly used in ROP attacks. In an example where a protectionfunction is used to change permissions in an OS, the special addresswould consist of the text region containing said protection function.

Identifying (220) one or more critical functions may include identifyinga set of one or more critical functions which correspond to potentialROP attacks. With respect to ROP attacks, each attack typically centersaround executing machine instruction sequences (or gadgets) that existin the corresponding program. These machine instruction sequencestypically end in a return instruction. Therefore, in at least someembodiments, the one or more identified critical functions may includeat least any functions or machine instruction sequences which end in areturn instruction. In other embodiments, a function or machineinstruction sequence ending in a return instruction may be deemedcritical only if the return instruction corresponds to an identifiedcritical region. The critical functions may additionally include branchoperations or jump operations, particularly if said branch or jumpoperations correspond to an identified critical region. In someembodiments, critical functions may additionally refer to any functionsthat impact system behavior. For example, “mprotect” on Linux™ changesexecution protection, and may therefore be identified as a criticalfunction.

Instrumenting (230) the one or more critical regions with ROP protectionmechanisms may include implementing one or more protection mechanismswith respect to the identified one or more critical regions. Forexample, once the one or more critical regions are identified, a shadowstack may be employed to monitor the one or more identified criticalregions. A shadow stack is a mechanism for maintaining control-flowintegrity by mitigating return address overwrites. Shadow stacks make arecord of legitimate return addresses for one or more function calls,and then check that a return address is correct with respect to anattempted function call before returning. With respect to someembodiments of the present invention, the implemented shadow stacks keepa record of legitimate return addresses for each identified criticalfunction. In additional embodiments, instrumenting (230) the one or morecritical regions may include implementing one or more nested protectionmechanisms configured to prevent ROP attacks.

Detecting (240) critical function on one or more of the identifiedcritical regions may include monitoring functions executed with respectto the identified critical regions. In at least one embodiment of thepresent invention, detecting (240) a call or return on one or more ofthe identified critical regions may include implementing a shadow stackto monitor and analyze call functions with respect to an identifiedcritical region. The implemented shadow stack may analyze only calls orreturns that have been identified as critical functions. In otherembodiments, the shadow stack may monitor and analyze each incomingfunction call, and only continues to comparing call or return values toan expected result if an incoming function call corresponds to acritical function. Once a critical function is detected, the methodcontinues by determining (250) whether values associated with thecritical function match expected values.

Determining (250) whether values associated with the detected criticalfunction match expected values may include comparing one or more valuescorresponding to the critical function to one or more correspondingexpected values. The compared values may be addresses to which thedetected critical function corresponds. For example, if the detectedcritical function includes a return operation, an associated value maybe the address to which the function is attempting to return. If thecritical function values match the one or more expected values, themethod returns to detecting (240) a critical function on one or morecritical regions. If the critical function values do not match the oneor more expected values, the method continues by activating (260) an ROPattack protection mechanism.

Activating (260) a return-oriented programming protection mechanism mayinclude blocking the attempted critical function from executing. In someembodiments, activating (260) a return-oriented programming protectionmechanism further includes reporting the attempted critical functionexecution. Such a report may include the details of the criticalfunction, including what kind of function it was, what address oraddresses it corresponded to, a timestamp, or any other pertinentexecution information.

FIG. 3 is a diagram depicting a sample address space 300 in accordancewith one embodiment of the present invention. As depicted, sampleaddress space includes addresses 310, critical regions 315, and a call320. The addresses 310 are depicted as white areas in the sample addressspace 300, and the critical regions 315 are depicted as slashed areas inthe sample address space 300. Sample address space 300 may correspond toan address space that is managed using an ROP protection method, such asROP protection method 200.

With respect to the depicted embodiment, critical regions 315 correspondto addresses with respect to which a return will trigger an ROPprotection mechanism. For example, call 320 originates in address 320C,which is not a critical region, but call 320 returns to critical region315A. As a result, in the depicted embodiment, call 320 would be flaggedfor analysis, and the values associated with call 320 (such as thereturn address) would be compared to a set of expected values. Thisanalysis might be executed by a shadow stack or any otherhardware/software mechanism available for ROP attack detection. If thesevalues match, or rather, if it is expected that call 320 would return tocritical region 315A, then the call is executed as intended. If thesevalues do not match, and the call's return value is expected to besomething other than critical region 315A, then the call is blocked, andmay be flagged as a potential ROP attack. For example, a processor faultor exception might be raised for privileged modes to analyze.Additionally, once a call or function has been identified as a potentialROP attack, it may be added to a log of potentially malicious calls orfunctions.

FIG. 4 depicts a block diagram of components of computer 400 inaccordance with an illustrative embodiment of the present invention. Itshould be appreciated that FIG. 4 provides only an illustration of oneimplementation and does not imply any limitations with regard to theenvironments in which different embodiments may be implemented. Manymodifications to the depicted environment may be made.

As depicted, the computer 400 includes communications fabric 402, whichprovides communications between computer processor(s) 404, memory 406,persistent storage 408, communications unit 412, and input/output (I/O)interface(s) 414. Communications fabric 402 can be implemented with anyarchitecture designed for passing data and/or control informationbetween processors (such as microprocessors, communications and networkprocessors, etc.), system memory, peripheral devices, and any otherhardware components within a system. For example, communications fabric402 can be implemented with one or more buses.

Memory 406 and persistent storage 408 are computer-readable storagemedia. In this embodiment, memory 406 includes random access memory(RAM) 416 and cache memory 418. In general, memory 406 can include anysuitable volatile or non-volatile computer-readable storage media.

One or more programs may be stored in persistent storage 408 for accessand/or execution by one or more of the respective computer processors404 via one or more memories of memory 406. In this embodiment,persistent storage 408 includes a magnetic hard disk drive.Alternatively, or in addition to a magnetic hard disk drive, persistentstorage 408 can include a solid state hard drive, a semiconductorstorage device, read-only memory (ROM), erasable programmable read-onlymemory (EPROM), flash memory, or any other computer-readable storagemedia that is capable of storing program instructions or digitalinformation.

The media used by persistent storage 408 may also be removable. Forexample, a removable hard drive may be used for persistent storage 408.Other examples include optical and magnetic disks, thumb drives, andsmart cards that are inserted into a drive for transfer onto anothercomputer-readable storage medium that is also part of persistent storage408.

Communications unit 412, in these examples, provides for communicationswith other data processing systems or devices. In these examples,communications unit 412 includes one or more network interface cards.Communications unit 412 may provide communications through the use ofeither or both physical and wireless communications links.

I/O interface(s) 414 allows for input and output of data with otherdevices that may be connected to computer 400. For example, I/Ointerface 414 may provide a connection to external devices 420 such as akeyboard, keypad, a touch screen, and/or some other suitable inputdevice. External devices 420 can also include portable computer-readablestorage media such as, for example, thumb drives, portable optical ormagnetic disks, and memory cards. Software and data used to practiceembodiments of the present invention can be stored on such portablecomputer-readable storage media and can be loaded onto persistentstorage 408 via I/O interface(s) 414. I/O interface(s) 414 also connectto a display 422.

Display 422 provides a mechanism to display data to a user and may be,for example, a computer monitor.

The programs described herein are identified based upon the applicationfor which they are implemented in a specific embodiment of theinvention. However, it should be appreciated that any particular programnomenclature herein is used merely for convenience, and thus theinvention should not be limited to use solely in any specificapplication identified and/or implied by such nomenclature.

The flowchart and block diagrams in the Figures illustrate thearchitecture, functionality, and operation of possible implementationsof systems, methods and computer program products according to variousembodiments of the present invention. In this regard, each block in theflowchart or block diagrams may represent a module, segment, or portionof code, which comprises one or more executable instructions forimplementing the specified logical function(s). It should also be notedthat, in some alternative implementations, the functions noted in theblock may occur out of the order noted in the figures. For example, twoblocks shown in succession may, in fact, be executed substantiallyconcurrently, or the blocks may sometimes be executed in the reverseorder, depending upon the functionality involved. It will also be notedthat each block of the block diagrams and/or flowchart illustration, andcombinations of blocks in the block diagrams and/or flowchartillustration, can be implemented by special purpose hardware-basedsystems that perform the specified functions or acts, or combinations ofspecial purpose hardware and computer instructions.

The present invention may be a system, a method, and/or a computerprogram product. The computer program product may include a computerreadable storage medium (or media) having computer readable programinstructions thereon for causing a processor to carry out aspects of thepresent invention.

The computer readable storage medium can be a tangible device that canretain and store instructions for use by an instruction executiondevice. The computer readable storage medium may be, for example, but isnot limited to, an electronic storage device, a magnetic storage device,an optical storage device, an electromagnetic storage device, asemiconductor storage device, or any suitable combination of theforegoing. A non-exhaustive list of more specific examples of thecomputer readable storage medium includes the following: a portablecomputer diskette, a hard disk, a random access memory (RAM), aread-only memory (ROM), an erasable programmable read-only memory (EPROMor Flash memory), a static random access memory (SRAM), a portablecompact disc read-only memory (CD-ROM), a digital versatile disk (DVD),a memory stick, a floppy disk, a mechanically encoded device such aspunch-cards or raised structures in a groove having instructionsrecorded thereon, and any suitable combination of the foregoing. Acomputer readable storage medium, as used herein, is not to be construedas being transitory signals per se, such as radio waves or other freelypropagating electromagnetic waves, electromagnetic waves propagatingthrough a waveguide or other transmission media (e.g., light pulsespassing through a fiber-optic cable), or electrical signals transmittedthrough a wire.

Computer readable program instructions described herein can bedownloaded to respective computing/processing devices from a computerreadable storage medium or to an external computer or external storagedevice via a network, for example, the Internet, a local area network, awide area network and/or a wireless network. The network may comprisecopper transmission cables, optical transmission fibers, wirelesstransmission, routers, firewalls, switches, gateway computers and/oredge servers. A network adapter card or network interface in eachcomputing/processing device receives computer readable programinstructions from the network and forwards the computer readable programinstructions for storage in a computer readable storage medium withinthe respective computing/processing device.

Computer readable program instructions for carrying out operations ofthe present invention may be assembler instructions,instruction-set-architecture (ISA) instructions, machine instructions,machine dependent instructions, microcode, firmware instructions,state-setting data, or either source code or object code written in anycombination of one or more programming languages, including an objectoriented programming language such as Smalltalk, C++ or the like, andconventional procedural programming languages, such as the “C”programming language or similar programming languages. The computerreadable program instructions may execute entirely on the user'scomputer, partly on the user's computer, as a stand-alone softwarepackage, partly on the user's computer and partly on a remote computeror entirely on the remote computer or server. In the latter scenario,the remote computer may be connected to the user's computer through anytype of network, including a local area network (LAN) or a wide areanetwork (WAN), or the connection may be made to an external computer(for example, through the Internet using an Internet Service Provider).In some embodiments, electronic circuitry including, for example,programmable logic circuitry, field-programmable gate arrays (FPGA), orprogrammable logic arrays (PLA) may execute the computer readableprogram instructions by utilizing state information of the computerreadable program instructions to personalize the electronic circuitry,in order to perform aspects of the present invention.

Aspects of the present invention are described herein with reference toflowchart illustrations and/or block diagrams of methods, apparatus(systems), and computer program products according to embodiments of theinvention. It will be understood that each block of the flowchartillustrations and/or block diagrams, and combinations of blocks in theflowchart illustrations and/or block diagrams, can be implemented bycomputer readable program instructions.

These computer readable program instructions may be provided to aprocessor of a general purpose computer, special purpose computer, orother programmable data processing apparatus to produce a machine, suchthat the instructions, which execute via the processor of the computeror other programmable data processing apparatus, create means forimplementing the functions/acts specified in the flowchart and/or blockdiagram block or blocks. These computer readable program instructionsmay also be stored in a computer readable storage medium that can directa computer, a programmable data processing apparatus, and/or otherdevices to function in a particular manner, such that the computerreadable storage medium having instructions stored therein comprises anarticle of manufacture including instructions which implement aspects ofthe function/act specified in the flowchart and/or block diagram blockor blocks.

The computer readable program instructions may also be loaded onto acomputer, other programmable data processing apparatus, or other deviceto cause a series of operational steps to be performed on the computer,other programmable apparatus or other device to produce a computerimplemented process, such that the instructions which execute on thecomputer, other programmable apparatus, or other device implement thefunctions/acts specified in the flowchart and/or block diagram block orblocks.

The descriptions of the various embodiments of the present inventionhave been presented for purposes of illustration, but are not intendedto be exhaustive or limited to the embodiments disclosed. Manymodifications and variations will be apparent to those of ordinary skillin the art without departing from the scope and spirit of the invention.The terminology used herein was chosen to best explain the principles ofthe embodiment, the practical application or technical improvement overtechnologies found in the marketplace, or to enable others of ordinaryskill in the art to understand the embodiments disclosed herein.

What is claimed is:
 1. A computer implemented method for preventingreturn-oriented programming (ROP) attacks, the method comprising:registering one or more critical regions, wherein a critical regioncorresponds to an address that has been selected to be monitored forpotential ROP attacks; identifying one or more critical functions,wherein a critical function corresponds to a function that has beenselected to be analyzed as a potential ROP threat; instrumenting the oneor more critical regions with ROP protection mechanisms; detecting acritical function execution attempt on one or more of the identifiedcritical regions; determining whether values associated with thecritical function match corresponding expected values; and responsive todetermining that values associated with the critical function do notmatch expected values, activating a return-oriented programmingprotection mechanism.
 2. The computer implemented method of claim 1,wherein a critical function is a function that impacts system behavior.3. The computer implemented method of claim 1, wherein activating areturn-oriented programming protection mechanisms includes blocking thecritical function execution attempt.
 4. The computer implemented methodof claim 1, further comprising reporting the critical function executionattempt as a potential ROP attack.
 5. The computer implemented method ofclaim 1, wherein instrumenting the one or more critical regions with ROPprotection mechanisms includes implementing a shadow stack with respectto the one or more critical regions.
 6. The computer implemented methodof claim 1, wherein determining whether values associated with thecritical function match corresponding expected values includesdetermining whether a return value associated with the critical functionmatches an expected return value.
 7. The computer implemented method ofclaim 1, further comprising receiving a set of critical functions and aset of critical regions.
 8. A computer program product for preventingreturn-oriented programming (ROP) attacks, the computer program productcomprising: one or more computer readable storage media and programinstructions stored on the one or more computer readable storage media,the program instructions comprising instructions to: register one ormore critical regions, wherein a critical region corresponds to anaddress that has been selected to be monitored for potential ROPattacks; identify one or more critical functions, wherein a criticalfunction corresponds to a function that has been selected to be analyzedas a potential ROP threat; instrument the one or more critical regionswith ROP protection mechanisms; detect a critical function executionattempt on one or more of the identified critical regions; determinewhether values associated with the critical function match correspondingexpected values; and responsive to determining that values associatedwith the critical function do not match expected values, activate areturn-oriented programming protection mechanism.
 9. The computerprogram product of claim 8, wherein a critical function is a functionthat impacts system behavior.
 10. The computer program product of claim8, wherein instructions to activate a return-oriented programmingprotection mechanisms comprise instructions to block the criticalfunction execution attempt.
 11. The computer program product of claim 8,further comprising instructions to report the critical functionexecution attempt as a potential ROP attack.
 12. The computer programproduct of claim 8, wherein instructions to instrument the one or morecritical regions with ROP protection mechanisms comprise instructions toimplement a shadow stack with respect to the one or more criticalregions.
 13. The computer program product of claim 8, whereininstructions to determine whether values associated with the criticalfunction match corresponding expected values comprise instructions todetermine whether a return value associated with the critical functionmatches an expected return value.
 14. The computer program product ofclaim 8, further comprising instructions to receive a set of criticalfunctions and a set of critical regions.
 15. A computer system forpreventing return-oriented programming (ROP) attacks, the computersystem comprising: one or more computer processors; one or morecomputer-readable storage media; program instructions stored on thecomputer-readable storage media for execution by at least one of the oneor more processors, the program instructions comprising instructions to:register one or more critical regions, wherein a critical regioncorresponds to an address that has been selected to be monitored forpotential ROP attacks; identify one or more critical functions, whereina critical function corresponds to a function that has been selected tobe analyzed as a potential ROP threat; instrument the one or morecritical regions with ROP protection mechanisms; detect a criticalfunction execution attempt on one or more of the identified criticalregions; determine whether values associated with the critical functionmatch corresponding expected values; and responsive to determining thatvalues associated with the critical function do not match expectedvalues, activate a return-oriented programming protection mechanism. 16.The computer system of claim 15, wherein a critical function is afunction that impacts system behavior.
 17. The computer system of claim15, wherein instructions to activate a return-oriented programmingprotection mechanisms comprise instructions to block the criticalfunction execution attempt.
 18. The computer system of claim 15, furthercomprising instructions to report the critical function executionattempt as a potential ROP attack.
 19. The computer system of claim 15,wherein instructions to instrument the one or more critical regions withROP protection mechanisms comprise instructions to implement a shadowstack with respect to the one or more critical regions.
 20. The computersystem of claim 15, wherein instructions to determine whether valuesassociated with the critical function match corresponding expectedvalues comprise instructions to determine whether a return valueassociated with the critical function matches an expected return value.